<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>职位详情</title>
		<%@include file="/view/common/js-css.jspf" %>
	</head>
	<body>	
		<center><h1>职位详情</h1></center>
		<hr>
		
		<h2>职位信息</h2>
		<p class="bg-primary">
			职位名称：${position.name }<br>
			工作职责：${position.duty }<br>
			能力要求：${position.ability }<br>
			薪资待遇：￥${position.salary1 }-${position.salary2 }<br>
			发布时间：<fmt:formatDate value="${position.releaseTime }" pattern="yyyy-MM-dd HH:mm:ss"/>
		</p>
		
		<h2>企业信息</h2>
		<p class="bg-info">
			企业名称：${position.companyName }<br>
			联  系 人： ${position.companyLinkman }<br>
			企业邮箱：${position.companyEmail }<br>
			联系电话：${position.companyPhone }<br>
			企业人数：${position.companyNumbers }<br>
			服务宗旨：${position.companySlogan }<br>
			企业地址：${position.companyAddress }<br>
		</p>
		<c:if test="${empty application && !empty talent }">
			<select id="resume">
				<option value="">-请选择简历-</option>
				<c:forEach items="${resumeList }" var="resume">
					<option value="${resume.id }">${resume.intention }</option>
				</c:forEach>
			</select>
		</c:if>
		<c:if test="${empty application }">
			<input type="button" class="btn btn-primary" value="申请职位" onclick="apply()">
		</c:if>
		<c:if test="${!empty application }">
			<span class="label label-info">该职位已申请，目前状态为：${application.statusStr }</span>
		</c:if>
		<script>
			/**
			*申请职位
			*/
			function apply() {
				if (!'${talent}') {
					layer.msg('请先登录，再申请职位~', {
					    icon: 1,
					    time: 2000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
					location = '<%=request.getContextPath()%>/view/talent/login.jsp?applyError=true';
					});
					return;
				}
				var resumeId = document.getElementById('resume').value;
				if (resumeId == '') {
					 layer.msg('请选择简历！', {icon : 0}); 
					return;
				}
				location = '<%=request.getContextPath()%>/PositionServlet?command=apply&positionId=${position.id}&resumeId=' + resumeId;
			}
		</script>
	</body>
</html>